package com.message.tcp.ip.socket.builder;

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.packager.GenericPackager;

import com.message.tcp.ip.socket.util.MessageDefinition;
import com.message.tcp.ip.socket.util.UtilPackage;

public class RevsReqMessageBuilderImp implements ReqMessageBuilder {
	private static final String MTI = "0420";
	private GenericPackager packager = MessageDefinition.getGenericPackager();
	@Override
	public byte[] buildReqMessage() throws ISOException {
		return buildRevsMessage();
	}
	private byte[] buildRevsMessage() throws ISOException{
		String mti     = MTI;
		String field02 = MessageDefinition.buildField02();
		String field03 = MessageDefinition.CWD00;
		String field04 = "000100000000";
		String field07 = MessageDefinition.buildField07();
		String field11 = MessageDefinition.buildField11();
		String field12 = MessageDefinition.buildField12();
		String field13 = MessageDefinition.buildField13();
		String field14 = MessageDefinition.buildField14();
		String field15 = MessageDefinition.buildField15();
		String field18 = MessageDefinition.buildField18();
		String field19 = MessageDefinition.buildField19();
		String field22 = MessageDefinition.buildField22();
		String field25 = MessageDefinition.buildField25();
		String field28 = MessageDefinition.buildField28();
		String field32 = MessageDefinition.buildField32();
		String field35 = MessageDefinition.buildField35();
		String field37 = MessageDefinition.buildField37(field11);
		String field41 = MessageDefinition.buildField41();
		String field42 = MessageDefinition.buildField42();
		String field43 = MessageDefinition.buildField43();
		String field49 = MessageDefinition.buildField49();
		String field90 = MessageDefinition.buildField90(mti, field11, field07, field32);
		
		ISOMsg isoMsg = new ISOMsg();
		isoMsg.setPackager(packager);
		isoMsg.setMTI(mti);
		isoMsg.set( 2, field02);
		isoMsg.set( 3, field03);
		isoMsg.set( 4, field04);
		isoMsg.set( 7, field07);
		isoMsg.set(11, field11);
		isoMsg.set(12, field12);
		isoMsg.set(13, field13);
		isoMsg.set(14, field14);
		isoMsg.set(15, field15);
		isoMsg.set(18, field18);
		isoMsg.set(19, field19);
		isoMsg.set(22, field22);
		isoMsg.set(25, field25);
		isoMsg.set(28, field28);
		isoMsg.set(32, field32);
		isoMsg.set(35, field35);
		isoMsg.set(37, field37);
		isoMsg.set(41, field41);
		isoMsg.set(42, field42);
		isoMsg.set(43, field43);
		isoMsg.set(49, field49);
		isoMsg.set(90, field90);
		byte[] msg = isoMsg.pack();
		return UtilPackage.addHeader(msg);
		
	}
}
